<template>
	<view>
		<view class="cy_list">
			<!-- <view class="cy_li">
				<text class="cy_li_tit t22">费率:</text>
				<text class="cy_li_tit t7 tri">1元</text>
				<text class="cy_li_tit t22">用户返红包:</text>
				<text class="cy_li_tit t7 tri">1元</text>
				<text class="cy_li_tit t22">实际收益:</text>
				<text class="cy_li_tit t20 tri">98元</text>
			</view> -->
			<view class="cy_li" v-show="jiazai==false">
				<text class="cy_li_tit t22" v-if="serviceAmount">费率:</text>
				<text class="cy_li_tit t20 tri" v-if="serviceAmount">{{serviceAmount/100}}元</text>
				<text class="cy_li_tit t22" v-if="redAmount">用户返红包:</text>
				<text class="cy_li_tit t20 tri" v-if="redAmount">{{redAmount/100}}元</text>
				<text class="cy_li_tit t22" v-if="seamount">实际收益:</text>
				<text class="cy_li_tit t20 tri" v-if="seamount">{{seamount/100}}元</text>
				<text class="cy_li_tit t20 tri" v-if="cuowu">{{cuowu}}</text>
			</view>
			<view class="zanwu" v-show="jiazai" style="padding-top: 4vw;padding-bottom: 3vw;"><text class="t7">当前收益无分润明细</text></view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				mainid: '',
				xq: [],
				serviceAmount:'',
				redAmount:'',
				id: '',
				jiazai: true,
				amount:0,
				seamount :0,
				cuowu:'',
			}
		},
		onLoad(opt) {
			var _this = this;
			if (opt.id) {
				_this.id = opt.id;
				_this.amount=opt.amount;
			}
			uni.getStorage({
				key: 'user',
				success: function(res) {
					console.log(res);
					_this.mainid = res.data.id;
					_this.log();
				}
			});
		},
		methods: {
			log() {
				// console.log(this.id);
				uni.request({
					header: {
						'Content-Type': 'application/x-www-form-urlencoded', //自定义请求头信息
					},
					url: getApp().globalData.url + 'mch/getTradeSplitInfo/' + this.id, //仅为示例，并非真实接口地址。
					method: 'post',
					data: {
						id: this.id, //	true	string
					},
					success: (res) => {
						uni.hideLoading(); //关闭加载动画
						console.log('收益详情：',res);
						if (res.data.status == '200') {
							if (res.data.data) {
								this.jiazai = false;
								let info=JSON.parse(res.data.data.info);
								console.log(info.serviceAmount);
								if(res.data.data.status==0){
									if(info.errMsg){
										this.cuowu=info.errMsg;
									}
								}
								this.serviceAmount=info.serviceAmount;
								this.redAmount=info.redAmount;
								this.seamount=this.amount-this.serviceAmount-this.redAmount;
							} else {

								this.jiazai = true;
							}
						}
					},
					fail: (error) => {
						uni.hideLoading();
						// this.checks = true
						uni.showToast({
							title: error,
							icon: 'none',
							duration: 2000
						});
						console.log(error)
					}
				});
			}
		}
	}
</script>

<style>
	.loading {
		text-align: center;
		line-height: 10vw;
	}

	.cy_user {
		width: 90%;
		height: auto;
		display: block;
		float: left;
		margin: 2vw 5%;
		background: -webkit-linear-gradient(#8A3DE2, #9C4BF9);
		background: -o-linear-gradient(#8A3DE2, #9C4BF9);
		background: -moz-linear-gradient(#8A3DE2, #9C4BF9);
		background: linear-gradient(#8A3DE2, #9C4BF9);
		border-radius: 1vw;
		padding: 4vw;
		box-shadow:0px 0px 5px #F2F2F2;
	}

	.cy_user_tit {
		width: 100%;
		height: 18vw;
		line-height: 8vw;
		display: block;
		float: left;
		text-align: left;
		margin-bottom: 2vw;
		border-bottom: 1px solid #fff;
		text-align: center;
		padding-bottom: 2vw;
	}

	.cy_user_into {
		width: 33.33%;
		height: auto;
		display: block;
		float: left;
		line-height: 7vw;
		display: block;
		float: left;
		margin: 2vw 0;
		text-align: center;
	}

	.cy_user_input {
		width: 20vw;
		height: 7vw;
		display: block;
		float: right;
		background: url(../../static/img/but.png)no-repeat top center;
		background-size: 100%;
		text-align: center;
		line-height: 7vw;
		margin: 1vw 0;
	}

	.cy_user_into text {
		margin-right: 2vw;
	}

	.cy_list {
		width: 90%;
		height: auto;
		display: block;
		float: left;
		margin: 2vw 5%;
		box-shadow:0px 0px 5px #F2F2F2;
		border-radius: 1vw;
		padding: 4vw;
		background: #fff;
	}

	.cy_li {
		width: 100%;
		height: auto;
		display: block;
		float: left;
		/* margin-bottom: 4vw; */
		/* border-bottom: 1px solid #F2F2F2; */
		padding: 4vw 0;
	}

	.cy_li:last-child {
		border: none;
	}

	.cy_li image {
		width: 10vw;
		height: 10vw;
		display: block;
		float: left;
		margin: 2vw 0;
		border: ;
	}

	.cy_li_tit {
		width: 50%;
		height: 10vw;
		line-height: 10vw;
		display: block;
		float: left;
	}

	.cy_li_info {
		width: 100%;
		height: auto;
		line-height: 7vw;
		display: block;
		float: left;
	}

	.tri {
		text-align: right;
	}

	.cy_list_tit {
		width: 100%;
		height: auto;
		line-height: 12vw;
		display: block;
		float: left;
		text-align: center;
		background: #fff;
	}

	.cy_li_i {
		width: auto;
		margin-right: 3vw;
	}

	.cy_li image.cy_li_info_img {
		width: 2vw;
		float: right;
	}
</style>
